<template>
  <div>
    这是home
    <router-link to="/news">到news</router-link>
    <button @click="addNum">+</button>
    {{ $store.state.num }}
    <button @click="reduceNum">-</button>

    <ul>
      <li v-for="item in $store.state.items" :key="item.id">
        <h4>{{item.name}}</h4>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HomePage',
  methods: {
    addNum () {
      this.$store.commit('ADD_NUM', 10)
    },
    reduceNum () {
      this.$store.commit('REDUCE_NUM', 5)
    }
  },
  created () {
    console.log(this.$store)
    this.$store.dispatch('FETCH_ITEMS', {
      page: 1,
      pageSize: 10
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
